;*****************************************************************************************************
;+
; NAME:
;
;      eWSAVE
;
; PURPOSE:
;
;      This routine saves the contents of the current valid IGL window
;      to a disk file. The output file format is determined from the
;      file extension. If the file format can not be found, the
;      default 'ps' is used to produce a PostScript file.
;
;      Valid type of outputs are : ['ps','png','jpg','bmp','tiff']
;                         
;
; CALLING SEQUENCE:
;
;      eWSAVE, filename
;
; ARGUMENTS:
;
;     FILENAME:   The full name (path+basename) of the desired output
;                 file. The default is 'graphic.ps'
;                 
; KEYWORD PARAMETERS:
;
;     _EXTRA:     Any keyword accepted by the PS_START routine (Coyote Library).
;    
; PACKAGE:
;
;    Interactive Graphics Library (IGL)
;
; AUTHORS:
;
;        RAPHAEL SADOUN
;        Graduate Student
;        Institut d'Astrophysique de Paris
;        98 bis boulevard Arago
;        75014 PARIS FRANCE
;        E-mail: raphael.sadoun@gmail.com
;
;
; MODIFICATION HISTORY:
;
;     Written by: Raphael Sadoun, 24 April 2012
;-
;*****************************************************************************************************
PRO eWSAVE, filename, _EXTRA=extra
  
  COMPILE_OPT idl2, HIDDEN
  ON_ERROR, 2

  ;; Initialize the global system variables
  IGL_InitSysVars

  ;; Get the current valid IGL window
  currentWindow = IGL_GetCurrentWindow()

  ;; If there is no valid window, return silently
  IF OBJ_ISA_VALID(currentWindow,'IGL_Window') EQ 0 THEN RETURN

  ;; Call the SaveWindow procedure of the current window to
  ;; produce the output file
  currentWindow -> SaveWindow, filename, _EXTRA=extra

END
